package com.ctsi.security.event.organ;

import com.ctsi.commons.event.AbstractObserver;
import com.ctsi.framework.common.startrun.ComponentFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public class UserLeaveUserGroupEvent extends AbstractObserver {
	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = -9030633694643384996L;
	private static Logger logger = LoggerFactory.getLogger(UserLeaveUserGroupEvent.class);
	private static OrganEventService organEventService;

	@Override
	public void onEvent(Object[] args) {
		logger.info("权限组织事件处理：组织结构用户离开用户组");
		if (args.length > 1) {
			String personId = (String) args[1];
			String groupId = (String) args[2];
			organEventService = this.getOrganEventService();
			organEventService.userLeaveUserGroupEvent(groupId, personId);
		}
	}

	private OrganEventService getOrganEventService() {
		if (organEventService == null) {
			organEventService = (OrganEventService) ComponentFactory.getApplicationContext().getBean("organEventService");
		}
		return organEventService;
	}

}
